<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<html>
<head>
	<title>广告类型管理</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/treetable.jsp" %>
	<script type="text/javascript">
		$(document).ready(function() {
			var tpl = $("#treeTableTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
			var data = ${fns:toJson(list)}, rootId = "0";
			addRow("#treeTableList", tpl, data, rootId, true);
			$("#treeTable").treeTable({expandLevel : 5});
		});
		function addRow(list, tpl, data, pid, root){
			for (var i=0; i<data.length; i++){
				var row = data[i];
				if ((${fns:jsGetVal('row.parentId')}) == pid){
					$(list).append(Mustache.render(tpl, {dict: {type:row.name,blank123:0}, pid: (root?0:pid), row: row}));
					addRow(list, tpl, data, row.id);
				}
			}
		}
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/sys/sysAdvertType/">广告类型列表</a></li>
		<li><a href="${ctx}/sys/sysAdvertType/form">广告类型添加</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="sysAdvertType" action="${ctx}/sys/sysAdvertType/" method="post" class="breadcrumb form-search">
		
	</form:form>
	<sys:message content="${message}"/>
	<table id="treeTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>栏目名称</th>
				<th>栏目编号</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody id="treeTableList"></tbody>
	</table>
	<script type="text/template" id="treeTableTpl">
		<tr id="{{row.id}}" pId="{{pid}}">
			<td><a href="${ctx}/sys/sysAdvertType/form?id={{row.id}}">
				{{row.name}}
			</a>
			</td>
			<td>
				{{row.id}}
			</a>
			</td>
			<td>
   				<a href="${ctx}/sys/sysAdvertType/form?id={{row.id}}" style="{{hidden}}">修改</a>
				<a href="${ctx}/sys/sysAdvertType/delete?id={{row.id}}" style="{{hidden}}" onclick="return confirmx('确认要删除该类型维护成功及所有子类型维护成功吗？', this.href)">删除</a>
				<a href="${ctx}/sys/sysAdvertType/form?pid={{row.id}}">添加下级类型维护成功</a> 
			</td>
		</tr>
	</script>
</body>
</body>
</html>